JavaScript is a versatile, high-level programming language primarily used for web development. It allows you to create dynamic and interactive web pages. JavaScript can be used for both client-side (in the browser) and server-side (with Node.js) development.
var x = 5;
let y = 6;
const z = x + y;
let number = 10;
let text = "Hello, World!";
let isTrue = true;
let person = { firstName: "John", lastName: "Doe" };
let numbers = [1, 2, 3, 4, 5];
let a = 10;
let b = 20;
let sum = a + b; // 30
function greet(name) {
return "Hello, " + name + "!";
}
console.log(greet("Alice")); // Hello, Alice!
if (x > y) {
console.log("x is greater than y");
} else {
console.log("x is not greater than y");
}
for (let i = 0; i < 5; i++) {
console.log(i);
}
// This is a single-line comment
/* This is a
multi-line comment */
JavaScript is heavily object-oriented. Objects are collections of key-value pairs, and arrays are ordered lists of values. JavaScript can respond to user actions like clicks, form submissions, and more. It can also interact with and manipulate the Document Object Model (DOM) to dynamically update the content and structure of web pages.
For more detailed information, you can check out resources like MDN Web Docs.